import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;


public class ArrayListTest {
	ArrayList list = new ArrayList();
	int n;
	Random rand = new Random();
	ArrayListTest (int n) {
		this.n = n;
			for (int j = 0; j < n; j++) {
				list.add(j);
			}
	}
	public double time() {
		long time1, time2, time3, time4;
		int i;
		Object object = new Object();
		time1 = System.nanoTime();
		//for (i = 0; i < n*1./2; i++) {
		for (i = 0; i<5; i++) {
			list.add(this.rand.nextInt(n), object );//add(this.rand.nextInt(n), rand.nextInt());
		}
		time2 = System.nanoTime();
		time3 = System.nanoTime();
		//for (int j = 0; j < n*1./2; j++) {
		//}
		for (int j = 0; j < 5; j++) {}
		time4 = System.nanoTime();
		return ((time2-time1)-(time4-time3))/i;
	}
}
